﻿using System.ComponentModel;
using System.Data;
using System.Windows;
using System.Windows.Data;
namespace WPFExcelReport
{
    public partial class TSKA02:UIKDADR
    {
        public TSKA02()
        {
            if (DesignerProperties.GetIsInDesignMode(this))
                return;
            MV = new VKUNDADR();
            DataContext = MV;
            InitializeComponent();  
        }
        public override void Window_Loaded(object sender, RoutedEventArgs e)
        {
            if (DesignerProperties.GetIsInDesignMode(this))
                return;
            if (IsLoaded)
                return;
            base.Window_Loaded(sender, e); 
        }
        public override void LOADBYAUF()
        {
            base.LOADBYAUF();
            if (ORDERNUM.Length < 16)
                return;
            dwData = TBMain.NewRow();
            dwData["KDAMANDANT"] = app.Mandant; 
            dwData["KDAKUNDNR"] =" AND KDAKUNDNR='"+ ORDERNUM.Substring(0, 8)+"'";
            dwData["KDAADRSL"] = " AND KDAADRSL='" + ORDERNUM.Substring(8, 8) + "'";
            SResult = TMV.QueryKUNDADR(dwData, 1);
            MergeData(SResult, false, true);
            Locate("KEY", ORDERNUM.Substring(0, 16));
        }
        public override void ManageCommand(object sender, RoutedEventArgs e)
        {
            if (IsManage)
            {
                LOADBYAUF();
            }
            else
            {
                VICC_WFEVENTS.SVWF.KD02(RUNID, KUNDNR);
            }
            base.ManageCommand(sender, e);
        }
         

        private void txtSearch_LostFocus(object sender, RoutedEventArgs e)
        {
            IsPopUp = false;
        }

        private void txtSearch_GotFocus(object sender, RoutedEventArgs e)
        {
            IsPopUp = true;
        }      
    }
}